package com.estun.backroundManagementService.enums;

import lombok.Getter;

/**
 * 排程状态枚举类
 */
@Getter
public enum WorkOrderTypeEnum {
    UNKNOWN(-1, "未知"),

    FACTORY_MES_PUSH(1, "MES派工"),
    LINE_MES_NEW(2, "产线自建"),
    ;

    private final Integer code;
    private final String description;

    WorkOrderTypeEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据状态码获取枚举值
     *
     * @param code 状态码
     * @return 对应的枚举值，如果没有匹配项返回 null
     */
    public static WorkOrderTypeEnum getByCode(Integer code) {
        for (WorkOrderTypeEnum status : WorkOrderTypeEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return UNKNOWN;
    }
}
